package com.west_traveler.find_page_fragment.findpageheaddragment;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.squareup.picasso.Picasso;
import com.west_traveler.entity.entity_editor.PerProject;
import com.west_traveler.ximalayafm.R;

/**
 * A simple {@link Fragment} subclass.
 */
public class FindPageHeadDiscoveryFragment extends Fragment implements View.OnClickListener {

    private PerProject per1;
    private PerProject per2;
    private PerProject per3;
    private PerProject per4;
    private LinearLayout ll_discovery_layout;

    public static FindPageHeadDiscoveryFragment getInstance(PerProject per1, PerProject per2, PerProject per3, PerProject per4) {
        FindPageHeadDiscoveryFragment fragment = new FindPageHeadDiscoveryFragment();
        Bundle bundle = new Bundle();
        bundle.putParcelable("per1", per1);
        bundle.putParcelable("per2", per2);
        bundle.putParcelable("per3", per3);
        bundle.putParcelable("per4", per4);
        fragment.setArguments(bundle);
        return fragment;
    }

    public FindPageHeadDiscoveryFragment() {
        // Required empty public constructor
    }
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        Bundle bundle = getArguments();
        per1 = bundle.getParcelable("per1");
        per2 = bundle.getParcelable("per2");
        per3 = bundle.getParcelable("per3");
        per4 = bundle.getParcelable("per4");
        return inflater.inflate(R.layout.fragment_find_page_head_discovery_item, container, false);
    }

    @Override
    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        ll_discovery_layout = ((LinearLayout) view.findViewById(R.id.ll_find_headvp_discovery_layout));
        TextView textView_c1 = (TextView) view.findViewById(R.id.c1).findViewById(R.id.tv_find_frg_headvp_discovery_text);
        ImageView imageView_c1 = (ImageView) view.findViewById(R.id.c1).findViewById(R.id.iv_find_frg_headvp_discovery_img);
        TextView textView_c2 = (TextView) view.findViewById(R.id.c2).findViewById(R.id.tv_find_frg_headvp_discovery_text);
        ImageView imageView_c2 = (ImageView) view.findViewById(R.id.c2).findViewById(R.id.iv_find_frg_headvp_discovery_img);
        TextView textView_c3 = (TextView) view.findViewById(R.id.c3).findViewById(R.id.tv_find_frg_headvp_discovery_text);
        ImageView imageView_c3 = (ImageView) view.findViewById(R.id.c3).findViewById(R.id.iv_find_frg_headvp_discovery_img);
        TextView textView_c4 = (TextView) view.findViewById(R.id.c4).findViewById(R.id.tv_find_frg_headvp_discovery_text);
        ImageView imageView_c4 = (ImageView) view.findViewById(R.id.c4).findViewById(R.id.iv_find_frg_headvp_discovery_img);
        textView_c1.setText(per1.getTitle());
        textView_c2.setText(per2.getTitle());
        textView_c3.setText(per3.getTitle());
        textView_c4.setText(per4.getTitle());
        Picasso.with(getActivity()).load(per1.getCoverPath()).into(imageView_c1);
        Picasso.with(getActivity()).load(per2.getCoverPath()).into(imageView_c2);
        Picasso.with(getActivity()).load(per3.getCoverPath()).into(imageView_c3);
        Picasso.with(getActivity()).load(per4.getCoverPath()).into(imageView_c4);
        imageView_c1.setOnClickListener(this);
        imageView_c2.setOnClickListener(this);
        imageView_c3.setOnClickListener(this);
        imageView_c4.setOnClickListener(this);

    }

    @Override
    public void onClick(View view) {

    }
}
